home *** CD-ROM | disk | FTP | other *** search
- /*------------------------------------------------------------*/
- /* filename - thistory.cpp */
- /* */
- /* function(s) */
- /* TOption member functions */
- /*------------------------------------------------------------*/
-
- /*------------------------------------------------------------*/
- /* */
- /* Turbo Vision - Version 1.0 */
- /* */
- /* */
- /* Copyright (c) 1991 by Borland International */
- /* All Rights Reserved. */
- /* */
- /*------------------------------------------------------------*/
-
- #define Uses_TOption
- #define Uses_TKeys
- #define Uses_TRect
- #define Uses_TEvent
- #define Uses_TInputLine
- #define Uses_TOptionWindow
- #define Uses_TWindow
- #define Uses_TCollection
- #define Uses_opstream
- #define Uses_ipstream
- #define Uses_TStreamableClass
- #include <tv.h>
- #include "TOption.h"
-
- #if !defined( __CTYPE_H )
- #include <ctype.h>
- #endif // __CTYPE_H
-
- #if !defined( __STRING_H )
- #include <String.h>
- #endif // __STRING_H
-
- #if !defined( __DOS_H )
- #include <Dos.h>
- #endif // __DOS_H
-
- #define cpOption "\x16\x17"
-
- const char * const near TOption::name = "TOption";
- __link( RView )
- __link( RInputLine )
-
- TStreamableClass ROption( TOption::name,
- TOption::build,
- __DELTA(TOption)
- );
- const char * near TOption::icon = "\xDE~\x19~\xDD";
-
-
- TOption::TOption( const TRect& bounds,
- TInputLine *aLink,
- TCollection *aList ) :
- TView(bounds),
- link( aLink ),
- items( aList )
- {
- options |= ofPostProcess;
- eventMask |= evBroadcast;
- }
-
- void TOption::shutDown()
- {
- link = 0;
- items = 0;
- TView::shutDown();
- }
-
- void TOption::draw()
- {
- TDrawBuffer b;
-
- b.moveCStr( 0, icon, getColor(0x0102) );
- writeLine( 0, 0, size.x, size.y, b );
- }
-
- TPalette& TOption::getPalette() const
- {
- static TPalette palette( cpOption, sizeof( cpOption )-1 );
- return palette;
- }
-
- void TOption::handleEvent( TEvent& event )
- {
- TOptionWindow *optionWindow;
- TRect r, p;
- ushort c;
-
- TView::handleEvent( event );
- if( event.what == evMouseDown ||
- ( event.what == evKeyDown &&
- ctrlToArrow( event.keyDown.keyCode ) == kbDown &&
- (link->state & sfFocused) != 0
- )
- )
- {
- link->select();
- r = link->getBounds();
- r.a.x--;
- r.b.x++;
- r.b.y += 7;
- r.a.y--;
- p = owner->getExtent();
- r.intersect( p );
- r.b.y--;
- optionWindow = initOptionWindow( r );
- if( optionWindow != 0 )
- {
- c = owner->execView( optionWindow );
- if( c == cmOK )
- {
- char rslt[256];
- optionWindow->getSelection( rslt );
- strncpy( link->data, rslt, link->maxLen );
- link->selectAll( True );
- link->drawView();
- }
- destroy( optionWindow );
- }
- clearEvent( event );
- }
- }
-
- TCollection *TOption::list()
- {
- return items;
- }
-
- void TOption::newList( TCollection *aList )
- {
- destroy( items );
- items = aList;
- }
-
- TOptionWindow *TOption::initOptionWindow( const TRect& bounds )
- {
- TOptionWindow *p = new TOptionWindow( bounds, items );
- p->helpCtx = link->helpCtx;
- return p;
- }
-
- void TOption::write( opstream& os )
- {
- TView::write( os );
- os << link << items;
- }
-
- void *TOption::read( ipstream& is )
- {
- TView::read( is );
- is >> link >> items;
- return this;
- }
-
- TStreamable *TOption::build()
- {
- return new TOption( streamableInit );
- }
-
- TOption::TOption( StreamableInit ) : TView( streamableInit )
- {
- }
-
-
-